home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gcc / ixemul_src.lha / ixemul-41.0 / library / ix_get_vars2.c < prev    next >
C/C++ Source or Header  |  1995-05-27  |  3KB  |  96 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  ix_get_vars2.c,v 1.1.1.1 1994/04/04 04:30:55 amiga Exp
  20.  *
  21.  *  ix_get_vars2.c,v
  22.  * Revision 1.1.1.1  1994/04/04  04:30:55  amiga
  23.  * Initial CVS check in.
  24.  *
  25.  *  Revision 1.4  1992/08/09  20:49:16  amiga
  26.  *  add cast
  27.  *
  28.  *  Revision 1.3  1992/07/04  19:14:44  mwild
  29.  *  add new variable, environ-in, primarly support for fork-emulation in ksh
  30.  *
  31.  * Revision 1.2  1992/05/20  01:32:00  mwild
  32.  * do atexit(_cleanup) here, ix_open is the wrong place
  33.  *
  34.  * Revision 1.1  1992/05/14  19:55:40  mwild
  35.  * Initial revision
  36.  *
  37.  */
  38.  
  39. #define KERNEL
  40. #include "ixemul.h"
  41. #include "kprintf.h"
  42.  
  43. #include <stdio.h>
  44.  
  45. extern char _ctype_[];
  46. extern int sys_nerr;
  47. extern void _cleanup();
  48.  
  49. /* too bad this is necessary, but the old function didn't know how to tell
  50.  * how many values to fill out, making later extensions impossible without
  51.  * breaking old executables. This one uses an explicit counter for this.
  52.  */
  53.  
  54. void
  55. ix_get_vars2 (int argc, char **ctype, int *_sys_nerr, 
  56.           struct Library **SysBase, struct Library **DOSBase,
  57.           FILE ***fpp, char ***environ_out, char ***environ_in)
  58. {
  59.   switch (argc)
  60.     {
  61.     case 7:
  62.       /* a `bit' kludgy.. */
  63.       if (environ_in) *environ_in = *u.u_environ;
  64.  
  65.     case 6:
  66.       if (environ_out) u.u_environ = environ_out;
  67.  
  68.     case 5:
  69.       if (fpp)
  70.         {
  71.       __init_stdinouterr ();
  72.           *fpp = (FILE **) &u.u_sF[0];
  73.       /* make sure all stdio buffers are flushed on exit() */
  74.       atexit (_cleanup);
  75.         }
  76.  
  77.     case 4:
  78.       if (DOSBase) *DOSBase = (struct Library *) ix.ix_dos_base;
  79.       
  80.     case 3:
  81.       if (SysBase) *SysBase =  (struct Library *) *(struct ExecBase **)4;
  82.       
  83.     case 2:
  84.       if (_sys_nerr) *_sys_nerr = sys_nerr;
  85.       
  86.     case 1:
  87.       if (ctype) *ctype = _ctype_;
  88.  
  89.     default:
  90.       break;
  91.     }
  92.    
  93.   /* now that system start is over, free the tracer */
  94.   u.u_trace_flags = 0;
  95. }
  96.